//
//  PragnantOrderDetailViewController.m
//  hospitalVIP
//
//  Created by Xiaoyan on 13-5-7.
//  Copyright (c) 2013年 MEETStudio. All rights reserved.
//

#import "PragnantOrderDetailViewController.h"

static ASIHTTPConnection *orderDetail_connect;

@interface PragnantOrderDetailViewController (){
    
     NSDictionary *orderDict;
}

@end

@implementation PragnantOrderDetailViewController

- (void)dealloc{
    
    if (orderDetail_connect != nil) {
        orderDetail_connect.connectionDelegate = nil;
        [orderDetail_connect release];
        orderDetail_connect = nil;
    }
    
    [weightLable release];
    [bloodLable release];
    [shuzhangLable release];
    [shousuoLable release];
    [uriProtenLable release];

    [orderLable release];
    
    [super dealloc];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (id)initWithOrderDict:(NSDictionary *)dict{
    
    self = [super init];
    if (self) {
        
        
        orderDict = dict;
        
    }
    return self;
    
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    UIImageView *bgview = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 300,200 )];
    bgview.image = [[UIImage imageNamed:@"writ bg_staggerer_iPhone.png"] stretchableImageWithLeftCapWidth:100 topCapHeight:20];
    [self.view insertSubview:bgview atIndex:1];
    [bgview release];

    
    
    weightLable.text = [NSString stringWithFormat:@"体重：%@Kg",[orderDict objectForKey:@"Weight"]];
    
    bloodLable.text = [NSString stringWithFormat:@"血糖：%@mmol/L",[orderDict objectForKey:@"BloodSugar"]];
    
    shuzhangLable.text = [NSString stringWithFormat:@"舒张压：%@mmol/L",[orderDict objectForKey:@"DiastolicPressure"]];
    
    shousuoLable.text = [NSString stringWithFormat:@"收缩压：%@mmol/L",[orderDict objectForKey:@"SystolicPressure"]];
    
    uriProtenLable.text = [NSString stringWithFormat:@"尿蛋白：%@mg/L",[orderDict objectForKey:@"UriaProtein"]];

    NSString *order = [orderDict objectForKey:@"Orders"];
    
    UIFont *font = [UIFont systemFontOfSize:14];
    CGSize size = CGSizeMake(300,2000);
    CGSize labelsize = [order sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeCharacterWrap];
    [orderLable setFrame:CGRectMake(orderLable.frame.origin.x, orderLable.frame.origin.y, 300, labelsize.height)];
    orderLable.text = [NSString stringWithFormat:@"医嘱：%@",order];
    
    [self loadDetail];
    
}


- (void)loadDetail{
    
    
    NSString *urlString = [NSString stringWithFormat:@"%@/MobileHealth/OrderDetailDataAction.aspx?DataID=%@",BASEURL,[orderDict objectForKey:@"DataID"]];
	NSURL *url = [NSURL URLWithString:urlString];
    
    
    if (orderDetail_connect != nil) {
        orderDetail_connect.connectionDelegate = nil;
        [orderDetail_connect release];
        orderDetail_connect = nil;
    }
    
    orderDetail_connect = [[ASIHTTPConnection alloc] initGETWithURL:url resultDict:YES isCache:YES];
    orderDetail_connect.connectionDelegate = self;
    
    [orderDetail_connect startAsynchronous];
    
    
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
